package com.zc.study.thread.线程的基础使用;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ThreadDemo2 implements Runnable {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Override
    public void run() {
        logger.debug("线程启动方式二:资源共享,我是通过实现接口方式实现的");
        try {
            SafeStopThread ss = new SafeStopThread();
            Thread thread = new Thread(ss);
            logger.debug("线程启动");
            thread.start();
            Thread.sleep(5000);
            ss.setStopMe(false);
            logger.debug("安全停止线程{}",ss.getStopMe());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Thread thread = new Thread(new ThreadDemo2());
        thread.start();
    }
}
